{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Credit Control Report",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "id" : {
      "type" : "integer",
      "description" : "Unique identifier for each generic extract file that is produced by CMP."
    },
    "interfaceCategory" : {
      "type" : "string",
      "maxLength" : 20,
      "enum" : [ "Credit Management" ],
      "description" : "CMP categorisation of the job associated with this file"
    },
    "interfaceType" : {
      "type" : "string",
      "maxLength" : 22,
      "enum" : [ "Credit Control" ],
      "description" : "Sub-categorisation of the job"
    },
    "version" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 99.99,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "batchDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : ""
    },
    "extractDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : ""
    },
    "recordCount" : {
      "type" : "integer",
      "minimum" : 0,
      "description" : ""
    },
    "accounts" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Account"
      }
    }
  },
  "required" : [ "id", "version", "recordCount" ],
  "definitions" : {
    "Account" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "accountNumber" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 99999999,
          "description" : "The number that uniquenly identifies the account."
        },
        "action" : {
          "type" : "string",
          "description" : "Enumeration."
        },
        "accountType" : {
          "$ref" : "#/definitions/AccountType",
          "description" : ""
        },
        "existingProcedure" : {
          "$ref" : "#/definitions/ExistingProcedure",
          "description" : ""
        },
        "newProcedure" : {
          "$ref" : "#/definitions/NewProcedure",
          "description" : ""
        },
        "accountBalance" : {
          "type" : "number",
          "description" : "This is the total outstanding amount of money that the account owes. This includes some debt that is not yet due. This does not take into account any amounts in query."
        },
        "balanceToRecover" : {
          "type" : "number",
          "description" : "This is the amount of money that the account owed at the time that it went into credit control. This is really only used in calculations when the ProgressionType of the procedure is of type 'BalanceToRecover'."
        },
        "amountDue" : {
          "type" : "number",
          "description" : "This is the total amount that is due on the account taking into account any amounts in query."
        },
        "eventToRaise" : {
          "$ref" : "#/definitions/EventToRaise",
          "description" : "This is the total amount that is due on the account taking into account any amounts in query."
        }
      },
      "required" : [ "accountType", "existingProcedure", "newProcedure", "accountBalance", "balanceToRecover", "amountDue" ]
    },
    "AccountType" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "description" : {
          "type" : "string",
          "description" : "The description of the account type."
        },
        "code" : {
          "type" : "string",
          "description" : "The code of the account type that the accout is currently on. Account Types are linked to credit control procedures."
        }
      },
      "required" : [ "description", "code" ]
    },
    "ExistingProcedure" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "type" : {
          "type" : "string",
          "description" : "This describes the Procedure Type. Presently only ACCOUNT is supported."
        },
        "code" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "This is the procedure code that the account is currently on."
        },
        "description" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "This is the stage on the existing procedure code that the accout is currently on."
        },
        "stage" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 999,
          "description" : "This is the stage on the existing procedure code that the accout is currently on."
        }
      },
      "required" : [ "type", "code", "description", "stage" ]
    },
    "NewProcedure" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "type" : {
          "type" : "string",
          "description" : "This describes the Procedure Type. Presently only ACCOUNT is supported."
        },
        "code" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "This is the procedure code that the account is expected to move onto. This may or may not be the same as the existing procedure code.."
        },
        "description" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Description of the new procedure that the account will move onto."
        },
        "stage" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 999,
          "description" : " This is the stage on the new Procedure code that the account is expected to move onto. This may or may not be the same as the exiting procedure stage."
        }
      },
      "required" : [ "type", "code", "description", "stage" ]
    },
    "EventToRaise" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "code" : {
          "type" : "string",
          "maxLength" : 4,
          "description" : "The event type of the workflow that will be raised against this account."
        },
        "description" : {
          "type" : "string",
          "maxLength" : 4,
          "description" : "The event code of the workflow that will be raised against this account."
        }
      }
    }
  }
}